package com.ecoolex.discount.sales.ws;

import com.ecoolex.discount.sales.core.manager.PaymentOrderManager;
import com.ecoolex.discount.sales.core.service.NihaoPayService;
import com.ecoolex.discount.sales.core.service.WeiXinPayService;
import com.ecoolex.discount.sales.entity.DiscountOrder;
import com.ecoolex.framework.common.exception.BizException;

import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Service
public class PaymentOrderServiceImpl implements PaymentOrderService {

    @Autowired
    private WeiXinPayService weiXinPayService;
    
    @Autowired
    private NihaoPayService nihaoPayService;
    
    @Autowired
    private PaymentOrderManager paymentOrderManager;

    @Override
    public Map weiXinPayApply(DiscountOrder order, String appId, String ipAdress, String createUser) {
        return weiXinPayService.payApply(order, appId, ipAdress, createUser);
    }

    @Override
    public String orderNotify(String body, String createUser) {
        return weiXinPayService.payNotify(body, createUser);
    }

    @Override
    public String refundNotify(String body, String createUser) {
        return weiXinPayService.refundNotify(body, createUser);
    }

	@Override
	public String nihaoPayApply(Integer nihaoPayType, DiscountOrder order, HttpServletRequest req, HttpServletResponse resp, String createUser) throws BizException {
		return nihaoPayService.pay(nihaoPayType, order, req, resp, createUser);
	}

	@Override
	public void nihaoPayOrderNotify(HttpServletRequest req, HttpServletResponse response, String createUser)  throws Exception {
		nihaoPayService.orderNotify(req, response, createUser);
	}
}
